package java111;

import java.util.Scanner;

public class Day16 {
    //https://www.nowcoder.com/practice/f094aed769d84cf3b799033c82fc1bf6?tpId=182&tqId=34710&ru=/exam/oj
    public String formatString(String string, char[] arg) {
        StringBuilder str = new StringBuilder(string);
        int i = 0, j = 0;
        for (; i < str.length() - 1; i++) {
            if (str.charAt(i) == '%' && str.charAt(i + 1) == 's') {
                str.replace(i, i + 2, arg[j++] + "");
            }
        }
        while (j < arg.length) {
            str.append(arg[j++]);
        }
        return str.toString();
    }



    // https://www.nowcoder.com/questionTerminal/99fa7be28d5f4a9d9aa3c98a6a5b559a
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int a = in.nextInt();
            int b = in.nextInt();
            int res = 0;
            for(int i = a; i <= b; i++){
                if(i <= 10){
                    continue;
                }
                int j = 0;
                int[] arr = new int[10];
                int tmp = i;
                while(tmp != 0){
                    arr[j++] = tmp % 10;
                    tmp /= 10;
                }
                boolean flag = false;
                for(int c = 0; c <= j && !flag; c++){
                    for(int r = 0; r <= j; r++){
                        if(r == c || arr[c] == 0){
                            continue;
                        }
                        if(isSu(arr[c] * 10 + arr[r])){
                            res++;
                            flag = true;
                            break;
                        }
                    }
                }
            }
            System.out.println(res);
        }
    }
    public static boolean isSu(int res){
        for(int i = 2; i < Math.sqrt(res) + 1; i++){
            if(res % i == 0){
                return false;
            }
        }
        return true;
    }


    //https://www.nowcoder.com/practice/e8480ed7501640709354db1cc4ffd42a?tpId=37&tqId=21286&ru=/exam/oj
    public static void main3(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            String str = in.next();
            int num = in.nextInt();
            int res = 0, index = 0;
            for (int i = 0, j = num; j < str.length(); i++, j++) {
                int tmp = judge(str.substring(i, j));
                if (tmp > res) {
                    res = tmp;
                    index = i;
                }
            }
            System.out.println(str.substring(index, index + num));
        }
    }
    public static int judge(String str) {
        int count = 0;
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == 'C' || str.charAt(i) == 'G') {
                count++;
            }
        }
        return count;
    }
}
